/*
 * @Author       : ljkt
 * @Version      : 1.0
 * @Date         : 2021-10-05 18:00:43
 * @LastEditors: ljkt
 * @LastEditTime: 2022-06-10 11:31:33
 * @Description  :
 */

#ifndef _Dev_Lh5815_H_
#define _Dev_Lh5815_H_

#define Dev_Lh5815_Task_Time ((u8_t)(10UL))
#define Dev_Lh5815_Addr (0x01)
#define Dev_Lh5815_Read_Cmd (0x03)
#define Dev_Lh5815_Write_Cmd (0x10)

#define Dev_Lh5815_Ver_Addr (1)            /* 地址2字节 */
#define Dev_Lh5815_Fuhao_Addr (2)          /* 称重状态符号 */
#define Dev_Lh5815_Wd_Zl_H16_Addr (3)      /* 稳定重量 */
#define Dev_Lh5815_Wd_Zl_L16_Addr (4)      /*   */
#define Dev_Lh5815_Js_Zl_H16_Addr (5)      /* 即时重量 */
#define Dev_Lh5815_Js_Zl_L16_Addr (6)      /*  */
#define Dev_Lh5815_Js_Zl_Nm_H16_Addr (7)   /* 即时重量内码 */
#define Dev_Lh5815_Js_Zl_Nm_L16_Addr (8)   /*  */
#define Dev_Lh5815_Ys_Nm_H16_Addr (9)      /* 原始内码值 */
#define Dev_Lh5815_Ys_Nm_L16_Addr (10)     /*  */
#define Dev_Lh5815_Js_H16_Addr (11)        /* 计数功能 */
#define Dev_Lh5815_Js_L16_Addr (12)        /*  */
#define Dev_Lh5815_Lb_Zf_H16_Addr (13)     /* 滤波振动幅度 */
#define Dev_Lh5815_Lb_Zf_L16_Addr (14)     /*  */
#define Dev_Lh5815_Bd_H16_Addr (15)        /* 标定 */
#define Dev_Lh5815_Bd_L16_Addr (16)        /*  */
#define Dev_Lh5815_Mlc_H16_Addr (17)       /* 满量程 */
#define Dev_Lh5815_Mlc_L16_Addr (18)       /*  */
#define Dev_Lh5815_Adc_Cyl_Addr (19)       /* AD采样率 */
#define Dev_Lh5815_Lb_Sd_Addr (20)         /* 滤波深度 */
#define Dev_Lh5815_Jm_Zt_Sd_Addr (21)      /* 加密状态 */
#define Dev_Lh5815_Fd_Xs_Addr (22)         /* 分度值小数点 */
#define Dev_Lh5815_Kj_Zl_Addr (23)         /* 开机置零范围 */
#define Dev_Lh5815_Ml_Zl_Addr (24)         /* 命令置零范围 */
#define Dev_Lh5815_Ld_Gz_Addr (25)         /* 零点跟踪范围 */
#define Dev_Lh5815_Lb_Gz_Addr (26)         /* 蠕变跟踪 */
#define Dev_Lh5815_Cz_Ms_Addr (27)         /* 称重模式 */
#define Dev_Lh5815_Dz_Addr (28)            /* 地址 */
#define Dev_Lh5815_Bound_Addr (29)         /* 波特率 */
#define Dev_Lh5815_Zl_Addr (30)            /* 置零 */
#define Dev_Lh5815_Fw_Cq_Addr (31)         /* 复位重启 */
#define Dev_Lh5815_Cs_Cs_Addr (32)         /* 初始化参数 */
#define Dev_Lh5815_Dq_Js_Adc_H16_Addr (33) /* 读取计数单重AD 值 */
#define Dev_Lh5815_Dq_Js_Adc_L16_Addr (34) /*  */
#define Dev_Lh5815_Xx_Xs_H16_Addr (35)     /* 线性系数 */
#define Dev_Lh5815_Xx_Xs_L16_Addr (36)     /*  */
#define Dev_Lh5815_Wd_Bc_Xs_Addr (37)      /* 温度补偿系数 */
#define Dev_Lh5815_Wd_Addr (38)            /* 温度 */
#define Dev_Lh5815_Wd_Kg_Flag_Addr (39)    /* 温补开关标志 */

#define Dev_Lh5815_Cgq_Fx_Addr (43) /* 传感器方向 */
#define Dev_Lh5815_Cz_Dw_Addr (69)  /* 传感器方向 */

#define Dev_Lh5815_TxRx gDrv_Uart1
#define Dev_Lh5815_Uart_Init() (Drv_Uart1_Init(9600))
#define Dev_Lh5815_Uart_Tx_Startup(len) (Drv_Uart1_Tx_Startup(len))
#define Dev_Lh5815_Tx_Status() (Drv_Uart1_Tx_Status())
#define Dev_Lh5815_Rx_Status() (Drv_Uart1_Rx_Status())

enum
{
    dev_lh5815_tx_cmd_standy,
    dev_lh5815_tx_cmd_ready_js_zl,
    dev_lh5815_tx_cmd_stan_bd_0000,
    dev_lh5815_tx_cmd_stan_bd_5000,
    dev_lh5815_tx_cmd_stan_ver,
};
typedef struct
{
    u8_t addr;
    u8_t cmd;
    u8_t byte_cnt;
    u8_t ver_addr_1;
    u8_t ver_addr_0;
    u8_t cz_zt_fh_1;
    u8_t cz_zt_fh_0;
    u8_t wd_zl_3;
    u8_t wd_zl_2;
    u8_t wd_zl_1;
    u8_t wd_zl_0;
    u8_t js_zl_3;
    u8_t js_zl_2;
    u8_t js_zl_1;
    u8_t js_zl_0;
    u8_t nc13;
    u8_t nc14;
    u8_t nc15;
    u8_t nc16;
    u8_t nc17;
    u8_t nc18;
    u8_t nc19;
    u8_t nc20;
    u8_t nc21;
    u8_t nc22;
    u8_t nc23;
    u8_t nc24;
    u8_t nc25;
    u8_t nc26;
    u8_t nc27;
    u8_t nc28;
    u8_t nc29;
    u8_t nc30;
    u8_t nc31;
    u8_t nc32;
    u8_t mlc_3;
    u8_t mlc_2;
    u8_t mlc_1;
    u8_t mlc_0;
    u8_t nc37;
    u8_t nc38;
    u8_t nc39;
    u8_t nc40;
    u8_t nc41;
    u8_t nc42;
    u8_t fdz_h8;
    u8_t fdz_l8;
    u8_t kj_zl_fw_h8;
    u8_t kj_zl_fw_l8;
    u8_t nc47;
    u8_t nc48;
    u8_t nc49;
    u8_t nc50;
    u8_t nc51;
    u8_t nc52;
    u8_t nc53;
    u8_t nc54;
    u8_t nc55;
    u8_t nc56;
    u8_t nc57;
    u8_t nc58;
    u8_t nc59;
    u8_t nc60;
    u8_t nc61;
    u8_t nc62;
    u8_t nc63;
    u8_t nc64;
    u8_t nc65;
    u8_t nc66;
    u8_t nc67;
    u8_t nc68;
    u8_t nc69;
    u8_t nc70;
    u8_t nc71;
    u8_t nc72;
    u8_t nc73;
    u8_t nc74;
    u8_t nc75;
    u8_t nc76;
    u8_t nc77;
    u8_t nc78;
    u8_t nc79;
    u8_t nc80;
    u8_t nc81;
    u8_t nc82;
    u8_t nc83;
    u8_t nc84;
    u8_t cgq_fx_h8;
    u8_t cgq_fx_l8;
    u8_t nc87;
    u8_t nc88;
    u8_t nc89;
    u8_t nc90;
    u8_t nc91;
    u8_t nc92;
    u8_t nc93;
    u8_t nc94;
    u8_t nc95;
    u8_t nc96;
    u8_t nc97;
    u8_t nc98;
    u8_t nc99;
    u8_t nc100;
    // u8_t nc101;
    // u8_t nc102;
    // u8_t nc103;
    // u8_t nc104;
    // u8_t nc105;
    // u8_t nc106;
    // u8_t nc107;
    // u8_t nc108;
    // u8_t nc109;
    // u8_t nc110;
    // u8_t nc111;
    // u8_t nc112;
    // u8_t nc113;
    // u8_t nc114;
    // u8_t nc115;
    // u8_t nc116;
    // u8_t nc117;
    // u8_t nc118;
    // u8_t nc119;
    // u8_t nc120;
    // u8_t nc121;
    // u8_t nc122;
    // u8_t nc123;
    // u8_t nc124;
    // u8_t nc125;
    // u8_t nc126;
    // u8_t nc127;
    // u8_t nc128;
    // u8_t nc129;
    // u8_t nc130;
    // u8_t nc131;
    // u8_t nc132;
    // u8_t nc133;
    // u8_t nc134;
    // u8_t nc135;
    // u8_t nc136;
    // u8_t cz_dw_h8;
    // u8_t cz_dw_l8;
    u8_t crc_0;
    u8_t crc_1;
} s_drv_lt5815_read_reg1_50_page_t;

typedef struct
{
    u8_t addr;
    u8_t cmd;
    u8_t byte_cnt;
    // u8_t nc101;
    // u8_t nc102;
    // u8_t nc103;
    // u8_t nc104;
    // u8_t nc105;
    // u8_t nc106;
    // u8_t nc107;
    // u8_t nc108;
    // u8_t nc109;
    // u8_t nc110;
    // u8_t nc111;
    // u8_t nc112;
    // u8_t nc113;
    // u8_t nc114;
    // u8_t nc115;
    // u8_t nc116;
    // u8_t nc117;
    // u8_t nc118;
    // u8_t nc119;
    // u8_t nc120;
    // u8_t nc121;
    // u8_t nc122;
    // u8_t nc123;
    // u8_t nc124;
    // u8_t nc125;
    // u8_t nc126;
    // u8_t nc127;
    // u8_t nc128;
    // u8_t nc129;
    // u8_t nc130;
    // u8_t nc131;
    // u8_t nc132;
    // u8_t nc133;
    // u8_t nc134;
    // u8_t nc135;
    // u8_t nc136;
    u8_t cz_dw_h8;
    u8_t cz_dw_l8;
    u8_t crc_0;
    u8_t crc_1;
} s_drv_lt5815_read_reg51_69_page_t;

typedef struct
{
    u8_t Tx_Cmd;
    s32_t Weight;
    u16_t Ver;
    u32_t Mlc;      //满量程
    u16_t Fdz;      //分度值
    u16_t Kj_Zl_Fw; //开机置零范围
    u16_t Cgq_Fx;   //传感器方向
    u16_t Cz_Dw;    //称重单位
} s_dev_lh5815_t;
extern s_dev_lh5815_t gDev_Lh5815;

#endif
